window.onload=function (){


    /**
     *  1. 页面初始化
     *      初始化select 、table 或者 初值
     *  2. 事件绑定
     *       按钮的click select的change
     * */

     var btnSubmit=  document.getElementById('btnSubmit');

    initSelect();


    btnSubmit.onclick = btnSubmitClick;

}

function btnSubmitClick(){
    var sltCity= document.getElementById('sltCity');

    var selectedOption = sltCity.selectedOptions[0];

    alert(selectedOption.text);
}


function initSelect(){

    var sltCity= document.getElementById('sltCity');

    for (var i = 0; i < cities.length; i++) {
        var opt = '<option value="'+cities[i].id+'">'+cities[i].name+'</option>'

        sltCity.innerHTML+=opt;
    }
}
